package com.di3fang.gateway.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult {

    private Integer errorcode = CommonEnum.SUCCESS.value();
    private String errormsg = CommonEnum.SUCCESS.msg();
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Object data;

    public static ResponseResult ok() {
        return new ResponseResult(CommonEnum.SUCCESS.value(), CommonEnum.SUCCESS.msg(), null);
    }

    public static ResponseResult ok(Object data) {
        return new ResponseResult(CommonEnum.SUCCESS.value(), CommonEnum.SUCCESS.msg(), data);
    }

    public static ResponseResult error() {
        return new ResponseResult(CommonEnum.FAIL.value(), CommonEnum.FAIL.msg(), null);
    }

    public static ResponseResult error(Integer errorcode, String errormsg) {
        return new ResponseResult(errorcode, errormsg, null);
    }
}
